package com.wf.classRoomTest.customer;

import java.util.concurrent.ArrayBlockingQueue;

/**
 * @author mpk
 * @since 2024/6/12 15:39:30
 * <p>
 * 生产者
 */
public class MyProduct extends Thread {


    private ArrayBlockingQueue<String> queue;

    public MyProduct(ArrayBlockingQueue<String> queue) {
        this.queue = queue;
    }

    @Override
    public void run() {

        while (true) {

                if (queue.isEmpty()) {
                    queue.offer("product");
                    System.out.println("生产者生产了一个产品");
                }


        }
    }
}
